package com.example;


import android.os.Parcel;
import android.os.Parcelable;

/**
 * Created by IntelliJ IDEA.
 * User: Andrzej
 * Date: 28.04.11
 * Time: 09:47
 * To change this template use File | Settings | File Templates.
 */
public class Task implements Parcelable
{
    String title;
    String where;
    String from;
    String to;
    String description;
    String id;

    public Task(String id, String title,String where,String from,String to, String description)
    {
        this.setId(id);
        this.title=title;
        this.where=where;
        this.from=from;
        this.to=to;
        this.description=description;
    }

    public Task(Parcel in) {
		readFromParcel(in);
	}



	@Override
	public int describeContents() {
		return 0;
	}

	@Override
	public void writeToParcel(Parcel dest, int flags) {

		// We just need to write each field into the
		// parcel. When we read from parcel, they
		// will come back in the same order
        dest.writeString(getId());
		dest.writeString(title);
        dest.writeString(where);
        dest.writeString(from);
        dest.writeString(to);
        dest.writeString(description);

	}

	/**
	 *
	 * Called from the constructor to create this
	 * object from a parcel.
	 *
	 * @param in parcel from which to re-create object
	 */
	private void readFromParcel(Parcel in) {


        setId(in.readString());
        title=in.readString();
        where=in.readString();
        from=in.readString();
        to=in.readString();
        description=in.readString();



    }

    /**
     *
     * This field is needed for Android to be able to
     * create new objects, individually or as arrays.
     *
     * This also means that you can use use the default
     * constructor to create the object and use another
     * method to hyrdate it as necessary.
     *
     * I just find it easier to use the constructor.
     * It makes sense for the way my brain thinks ;-)
     *
     */
    public static final Parcelable.Creator CREATOR =
    	new Parcelable.Creator() {
            public Task createFromParcel(Parcel in) {
                return new Task(in);
            }

            public Task[] newArray(int size) {
                return new Task[size];
            }
        };

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }
}
